package war
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	/**
	 * 
	 * @author war
	 * 
	 */	
	public class Addpic extends Sprite
	{
		/**
		 * 玩家MC数组；
		 */		
		public var mcArr:Array=[];
		/**
		 * 电脑1MC数组；
		 */		
		public var mcPlayer1Arr:Array=[];
		/**
		 * 电脑2MC数组；
		 */		
		public var mcPlayer2Arr:Array=[];
		public function Addpic()
		{
			super();
			var deal:Deal=new Deal();
			for (var k:int = 0; k < deal.arr1.length; k++) 
			{
				
				var a:MovieClip=new MovieClip();
				addChild(a);
				//-------------------------------------
				onHitArea(a,k*25+150,460);
				//-------------------------------------
				mcArr.push(a);
				mcArr[k].addChild(deal.arr1[k]["name"]);
				mcArr[k].value=deal.arr1[k].value;
				mcArr[k].chu=false;
				mcArr[k].addEventListener(MouseEvent.CLICK,targetClick);
				mcArr[k].x=k*25+150;
				mcArr[k].y=460;
				
			}
			for (var i:int = 0; i < deal.arr2.length; i++) 
			{
				var	b:MovieClip=new MovieClip();				
				addChild(b);
				//-------------------------------------
				onHitArea(b,20,i*30);
				//-------------------------------------
				mcPlayer1Arr.push(b);
				mcPlayer1Arr[i].addChild(deal.arr2[i].name);
				mcPlayer1Arr[i].value=deal.arr2[i].value;
				mcPlayer1Arr[i].x=20;
				mcPlayer1Arr[i].y=30*i;
			}
			for (var j:int = 0; j < deal.arr3.length; j++) 
			{
				var	c:MovieClip=new MovieClip();				
				addChild(c);
				//-------------------------------------
				onHitArea(c,700,30*j);
				//-------------------------------------
				mcPlayer2Arr.push(c);
				mcPlayer2Arr[j].addChild(deal.arr3[j].name);
				mcPlayer2Arr[j].value=deal.arr3[j].value;				
				mcPlayer2Arr[j].x=700;
				mcPlayer2Arr[j].y=30*j;
			}
		}
		/**
		 * 区域点击检测
		 * @param mc 
		 * @param numX
		 * @param numY
		 * 
		 */		
		private function onHitArea(mc:MovieClip,numX:int,numY:int):void
		{
			var square2:Sprite = new Sprite();
			square2.graphics.beginFill(0xffffff);
			square2.graphics.drawRect(0, 0, 112, 171);
			addChild(square2)
			square2.alpha=0;
			square2.mouseEnabled = false;
			mc.hitArea=square2;
			square2.x=numX;
			square2.y=numY;
		}
		protected function targetClick(e:MouseEvent):void
		{
			
			if(e.target.chu==false){
				e.target.y=420;				
				e.target.chu=true;
				//trace(e.target.value);
			}else {
				e.target.y=460;
				e.target.chu=false;
			}
		}
	}
}